package com.seari.web.controller;

import com.seari.bean.EquipmentName;
import com.seari.pojo.MessageBean;
import com.seari.service.EquipmentTreeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @ClassName equipmentTreeController
 * @author zhanghongyang
 * @Date 2020/7/7
 **/
@RestController
public class EquipmentTreeController {

    /**
     *
     * 故障树设备查询
     */
    @Autowired
    private EquipmentTreeService equipmentTreeService;

    @RequestMapping(value = "/getEquipment/tree")
    public MessageBean getEquipment(){

        MessageBean messageBean = new MessageBean();

        try {
            Map<String, Object> dataMap = new HashMap<String, Object>();

            List<Map<String, Object>> data1 = equipmentTreeService.getdDsposeEquipmentInfo();
            dataMap.put("data1", data1);
            messageBean.setType("success");
            messageBean.setCode("1000");
            messageBean.setMessage("故障树设备查询获取成功 ");
            messageBean.setData(dataMap);
        } catch (Exception e) {
            e.printStackTrace();
            messageBean.setType("fail");
            messageBean.setCode("3000");
            messageBean.setMessage("故障树设备查询获取失败");
        }
        return messageBean;
    }


}
